package com.xiaoq.shop.vo;

import io.swagger.annotations.ApiModelProperty;
import org.joda.time.DateTime;

/**
 * Created by chenjh on 2017/11/7.
 */
public class UserCouponVo {

    @ApiModelProperty(name = "userCouponId", value = "优惠券ID")
    private String userCouponId;

    @ApiModelProperty(name = "userId", value = "用户Id", position=10)
    private String userId;

    @ApiModelProperty(name = "shopId", value = "shop id", position=20)
    private String shopId;

    @ApiModelProperty(name = "shopOrderId", value = "订单ID", position=30)
    private String shopOrderId;

    @ApiModelProperty(name = "couponTemplateCode", value = "优惠券模板编码", position=40)
    private Long couponTemplateCode;

    @ApiModelProperty(name = "couponInstanceCode", value = "优惠券实例编码", position=50)
    private String couponInstanceCode;

    @ApiModelProperty(name = "denomination", value = "面额", position=60)
    private int denomination;

    @ApiModelProperty(name = "minSpendingAmountForUse", value = "可以使用此优惠券的最低消费金额", position=70)
    private int minSpendingAmountForUse;

    @ApiModelProperty(name = "state", value = "状态,-1未使用| 0,未使用 | 1,已使用 | 2,已过期", position=80)
    private int state;

    @ApiModelProperty(name = "effectiveDate", value = "生效日期", position=90)
    private Long effectiveDate;

    @ApiModelProperty(name = "expirationDate", value = "失效日期", position=100)
    private Long expirationDate;

    @ApiModelProperty(name = "getTime", value = "领券时间", position=110)
    private Long getTime;

    @ApiModelProperty(name = "consumedTime", value = "消券时间", position=120)
    private Long consumedTime;

    @ApiModelProperty(name = "showExpiredStr", value = "快过期", position=130)
    private String showExpiredStr;

    @ApiModelProperty(name = "duringUseDateStr", value = "使用期间2017.8.27-2017.9.27", position=150)
    private String duringUseDateStr;

    @ApiModelProperty(name = "shopName", value = "小店名称", position=160)
    private String shopName;

    @ApiModelProperty(name = "shopLogo", value = "小店LOGO", position=170)
    private String shopLogo;

    public enum StateEnum {
        LOCKED(-1), //锁定状态
        NOUSE(0),  //未使用
        BEUSEED(1), //已使用
        EXPIRED(2), //已过期
        DELETE(3); //已删除
        private int code;
        StateEnum(int code){
            this.code = code;
        }
        public int value(){
            return this.code;
        }
    }

    public String getShowExpiredStr() {
        DateTime expirationDateTime = new DateTime(expirationDate);
        DateTime now = new DateTime();
        if(now.plusDays(4).getMillis() >= expirationDateTime.getMillis()
                && state==StateEnum.NOUSE.value()){
            return "快过期";
        }
        return "";
    }

    public String getDuringUseDateStr() {
        DateTime effectiveDateTime = new DateTime(effectiveDate);
        DateTime expirationDateTime = new DateTime(expirationDate);
        duringUseDateStr = effectiveDateTime.toString("yyyy.M.dd")
                + "-" + expirationDateTime.toString("yyyy.M.dd");
        return duringUseDateStr; //2017.11.06-2017.11.16
    }

	public String getUserCouponId() {
		return userCouponId;
	}

	public void setUserCouponId(String userCouponId) {
		this.userCouponId = userCouponId;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getShopId() {
		return shopId;
	}

	public void setShopId(String shopId) {
		this.shopId = shopId;
	}

	public String getShopOrderId() {
		return shopOrderId;
	}

	public void setShopOrderId(String shopOrderId) {
		this.shopOrderId = shopOrderId;
	}

	public Long getCouponTemplateCode() {
		return couponTemplateCode;
	}

	public void setCouponTemplateCode(Long couponTemplateCode) {
		this.couponTemplateCode = couponTemplateCode;
	}

	public String getCouponInstanceCode() {
		return couponInstanceCode;
	}

	public void setCouponInstanceCode(String couponInstanceCode) {
		this.couponInstanceCode = couponInstanceCode;
	}

	public int getDenomination() {
		return denomination;
	}

	public void setDenomination(int denomination) {
		this.denomination = denomination;
	}

	public int getMinSpendingAmountForUse() {
		return minSpendingAmountForUse;
	}

	public void setMinSpendingAmountForUse(int minSpendingAmountForUse) {
		this.minSpendingAmountForUse = minSpendingAmountForUse;
	}

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	public Long getEffectiveDate() {
		return effectiveDate;
	}

	public void setEffectiveDate(Long effectiveDate) {
		this.effectiveDate = effectiveDate;
	}

	public Long getExpirationDate() {
		return expirationDate;
	}

	public void setExpirationDate(Long expirationDate) {
		this.expirationDate = expirationDate;
	}

	public Long getGetTime() {
		return getTime;
	}

	public void setGetTime(Long getTime) {
		this.getTime = getTime;
	}

	public Long getConsumedTime() {
		return consumedTime;
	}

	public void setConsumedTime(Long consumedTime) {
		this.consumedTime = consumedTime;
	}

	public String getShopName() {
		return shopName;
	}

	public void setShopName(String shopName) {
		this.shopName = shopName;
	}

	public String getShopLogo() {
		return shopLogo;
	}

	public void setShopLogo(String shopLogo) {
		this.shopLogo = shopLogo;
	}

	public void setShowExpiredStr(String showExpiredStr) {
		this.showExpiredStr = showExpiredStr;
	}

	public void setDuringUseDateStr(String duringUseDateStr) {
		this.duringUseDateStr = duringUseDateStr;
	}

}
